package ar.edu.utn.frba.dds.tp.ui;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.WindowOwner;

import ar.edu.utn.frba.dds.tp.code.Asientos.AsientoDeVuelo;
import ar.edu.utn.frba.dds.tp.ui.appModel.ComprasManager;
import ar.edu.utn.frba.dds.tp.ui.appModel.ReservasManager;

@SuppressWarnings("serial")
public class AccionConcretadaWindow extends ResultadosAccionesWindow {

	private String estado;
	private AsientoDeVuelo asiento;

	public AccionConcretadaWindow(WindowOwner owner, BuscarWindow model) {
		super(owner, model);
		this.asiento=model.getModelObject().getAsientoSeleccionado();
		this.estado=asiento.getEstado().toString().toLowerCase();
	}

	@Override
	protected void buildAviso(Panel mainPanel) {
		Panel aviso = new Panel(mainPanel);
		aviso.setLayout(new HorizontalLayout());
				
		new Label(aviso).setText("El asiento " + asiento.getNumeroDeAsiento());
		new Label(aviso).setText(" ha sido "+ estado + " exitosamente.");
	}

	@Override
	protected void addActions(Panel actionsPanel) {
		new Button(actionsPanel)
		.setCaption("Seguir Buscando")
		.onClick(new MessageSend(this, "close")); 
		new Button(actionsPanel)
		.setCaption("Ver mis reservas")
		.onClick(new MessageSend(this, "verReservas"));
		new Button(actionsPanel)
		.setCaption("Ver mis compras")
		.onClick(new MessageSend(this, "verCompras"));
	}
	
	public void verReservas(){
		close();
		new TransaccionesWindow(getOwner(), new ReservasManager(), getModelObject().user, "Reservas de ").open();
	}
	
	public void verCompras(){
		close();
		new TransaccionesWindow(getOwner(), new ComprasManager(), getModelObject().user, "Compras de ").open();
	}

}
